#include <iostream>
#include <string>
#include <queue>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;


int charToInt(char c) 
{
	int i = -1;
	switch (c) {
		case 'A': case 'B': case 'C':
			i = 2;
			break;
		case 'D': case 'E': case 'F':
			i = 3;
			break;
		case 'G': case 'H': case 'I':
			i = 4;
			break;
		case 'J': case 'K': case 'L':
			i = 5;
			break;
		case 'M': case 'N': case 'O':
			i = 6;
			break;
		case 'P': case 'R': case 'S':
			i = 7;
			break;
		case 'T': case 'U': case 'V':
			i = 8;
			break;
		case 'W': case 'X': case 'Y':
			i = 9;
			break;
		default:
			break;
	}
	return i;
}

int split(string *arr, int p, int q)
{
	string flag = arr[p];

	int toSwap = p + 1;
	for (int i = p + 1; i <= q; i++) {
		if (arr[i].compare(flag) < 0) {
			string temp = arr[toSwap];
			arr[toSwap] = arr[i];
			arr[i] = temp;
			++toSwap;
		}
	}
	--toSwap;
	string temp = arr[toSwap];
	arr[toSwap] = flag;
	arr[p] = temp;

	return toSwap;
}

void quickSort(string *arr, int p, int q)
{
	/*int s;
	if (p < q) {
		s = split(arr, p, q);
		quickSort(arr, p, s - 1);
		quickSort(arr, s + 1, q);
	}*/
	if (p > q)
		return;
	typedef pair<int, int> intPair;

	queue<intPair> que;
	que.push(intPair(p, q));
	while (!que.empty()) {
		intPair inPa = que.front();
		que.pop();
		int s = split(arr, inPa.first, inPa.second);
		if (s - 1 > inPa.first)
			que.push(intPair(inPa.first, s - 1));

		if (s + 1 < inPa.second )
			que.push(intPair(s + 1, inPa.second));

	}
	
	
}

int compareFunc(const void* a, const void* b)
{
	return (*(string*)a).compare(*(string*)b);
}

int main(int argc, char* argv[])
{
	string s;
	int n = 0;
	getline(cin, s);
	istringstream stream(s);
	stream>>n;
	//string* result = new string[n];
	vector<string> result;

	int size = 0;
	while (size < n) {
		//string s;
		//cin>>s;
		getline(cin, s, '\n');
		//scanf("%s", s.c_str());

		int resultIdx = 0;
		string temp;
		for (int i = 0; i < (int)s.size(); i++) {
			if (s[i] == '-') 
				continue;
			
			if (resultIdx == 3) {
				temp.append(1, '-');
				++resultIdx;
			}

			if (s[i] >= '0' && s[i] <= '9') {				
				temp.append(1, s[i]);
				++resultIdx;
			} else if (s[i] >= 'A' && s[i] <= 'Z') {
				char ch = charToInt(s[i]) + '0';
				temp.append(1, ch);
				++resultIdx;
			}
		}
		result.push_back(temp);
		++size;
	}
	//quickSort(result, 0, n - 1);
	//qsort(result, n, result[0].size(), compareFunc);
	sort(result.begin(), result.end());

	bool noDup = false;
	int number = 1;
	for (int i = 0; i < n - 1; i++)
	{
		if (result[i].compare(result[i + 1])/* && !isNew*/) {
			if (number > 1) {
				cout<< result[i] << " "<<number<<endl;
				number = 1;
				
				noDup = true;
			}
		} else {
			number++;
			if (i == n- 2) {
				noDup = true;
				cout<<result[i]<<" "<<number<<endl;
			}
		}
	}

	if (!noDup)
		cout<<"No duplicates."<<endl;
	return 0;
}